﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EnemyMove 
{


    Rigidbody2D rigid;

    //void Start()
    //{
    //    rigid = GetComponent<Rigidbody2D>();
    //}

    //private void FixedUpdate()
    //{
    //    Vector3 fornt = new Vector3(-0.5f, 0, 0);

    //    if (transform.localScale.x < 0)
    //    {
    //        fornt = new Vector3(0.5f, 0, 0);
    //    }

    //    Vector3 beg = transform.position + new Vector3(0, -0.1f, 0);
    //    Vector3 down = new Vector3(0, -0.8f, 0);

    //    Debug.DrawLine(beg, beg + fornt * 0.8f, Color.red);
    //    RaycastHit2D hit;
    //    hit = Physics2D.Raycast(beg, fornt, 0.8f, LayerMask.GetMask("Ground"));

    //    if (hit.collider != null)
    //    {
    //        transform.localScale = new Vector3(transform.localScale.x * -1, transform.localScale.y, transform.localScale.z);
    //        Destroy(hit.collider.gameObject);
    //    }

    //    Debug.DrawLine(beg, beg + (fornt + down).normalized * 0.5f, Color.red);
    //    if (!Physics2D.Raycast(beg, fornt + down, 0.5f, LayerMask.GetMask("Ground")))
    //    {
    //        transform.localScale = new Vector3(transform.localScale.x * -1, transform.localScale.y, transform.localScale.z);
    //    }

    //    rigid.velocity = new Vector2(fornt.x * speed, rigid.velocity.y);

    //}
    //// Update is called once per frame
    
}
